extension :dependencies => :wolips do

  set(:_wolips_dependencies) do
    sources

    classpath_fpath = File.join(revision_build.src_path, ".classpath")
    classpath_xml = nil
    open(classpath_fpath, "r") { |f| classpath_xml = f.read }
    doc = REXML::Document.new classpath_xml
    entries = REXML::XPath.match(doc, %q{//classpath/classpathentry[@kind='con']/@path})

    entries.inject([]) do |result, entry|
      result << $1 if entry.value =~ /WOFramework\/(.*)/
      result
    end
  end

  set :treat_wolips_deps_as_runtime, true unless exists?(:treat_wolips_deps_as_runtime)

  task :fill_build_dependencies do
    execute_previous
    build_dependencies.concat(_wolips_dependencies)
  end

  task :fill_runtime_dependencies do
    execute_previous
    runtime_dependencies.concat(treat_wolips_deps_as_runtime ? _wolips_dependencies : [])    
  end

end

